package com.gxa.service.gouhuoservice.Impl;

import com.gxa.common.R;
import com.gxa.mapper.gouhuomapper.ShangPin46Mapper;
import com.gxa.pojo.ShangPin;
import com.gxa.service.gouhuoservice.ShangPin46Service;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service

public class ShangPin46ImplService implements ShangPin46Service {
    @Autowired
    private ShangPin46Mapper shangPin46Mapper;

    @Override
    public R selectAllShangPinForPage(int currentPage, int pageSize) {

        R r= new R();
        List<ShangPin> shangPins = shangPin46Mapper.selectAllShangPinForPage( currentPage ,pageSize);
        r.setCode(200);
        r.setMsg("查询成功！");
        r.setData(shangPins);
        return r;
    }


    public R selectAllShangPin(int currentPage,int pageSize,String shangPinBianHao,String guiGeXingHao,String shangPinMingCheng,String unitName) {

        R r = new R();
        //分页
        int index=(currentPage-1)*pageSize;
        List<ShangPin> shangPins = shangPin46Mapper.selectAllShangPin(index, pageSize,
                shangPinBianHao, guiGeXingHao, shangPinMingCheng,unitName);
        r.setCode(200);
        r.setMsg("查询成功！");
        System.out.println(shangPins);
        r.setData(shangPins);
        return r;
    }
//        R r = new R();
//        List<ShangPin> shangPins = shangPin46Mapper.selectAllShangPinForPage(index,size);
//        if (shangPins != null) {
//            r.setCode(200);
//            r.setMsg("查询成功！");
//            r.setData(shangPins);
//        }
//        return r;

}
